# -*- coding:utf-8 -*-

import urllib.request as request
import re

# 1、网址url  --豆瓣网

headers = {'User-Agent':'Mozilla/5.0 3578.98 Safari/537.36'}

url = 'https://c-ssl.duitang.com/uploads/item/201208/30/20120830173930_PBfJE.thumb.700_0.jpeg'

url = request.Request(url, headers=headers)
# 2、直接请求  返回结果R
response =  request.urlopen(url)

with open('aa.pdf','wb') as code:
    code.write(response.read)